package com.goodmr.passport.webapp.controller;

import com.goodmr.passport.webapp.model.request.RefreshTokenReq;
import com.goodmr.passport.webapp.model.response.RefreshTokenResp;
import com.goodmr.passport.webapp.model.response.VerifyTokenResp;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 帐号鉴权
 *
 * @author <a href="mailto:bingdong13@msn.com">bigo</a>
 */
@RestController
@RequestMapping(path = "/passport/auth")
public class AuthController {

    /**
     * 校验 access token 合法性
     *
     * @param request 请求数据包
     * @return 校验通过后，返回帐号id，否则返回异常
     */
    @GetMapping("/token")
    public ResponseEntity<VerifyTokenResp> verifyToken(HttpServletRequest request) {
        return null;
    }

    /**
     * access token 过期，
     * 通过 refresh token 交换新的 token
     *
     * @param body 请求数据包
     * @return 新的 token
     */
    @PostMapping("/refresh")
    public ResponseEntity<RefreshTokenResp> refreshToken(@Valid @RequestBody RefreshTokenReq body) {
        return null;
    }
}
